﻿Public Class Win32
    'API Declarations
    Private Declare Function GetDiskFreeSpace Lib "kernel32.dll" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, ByRef lpSectorsPerCluster As Long, ByRef lpBytesPerSector As Long, ByRef lpNumberOfFreeClusters As Long, ByRef lpTotalNumberOfClusters As Long) As Long
    'Call this function to get the Amount of Free Disk Space (in Bytes)
    'Pass to this function only the letter of the drive
    Public Shared Function GetFreeDiskSpace(ByVal path As String) As Long
        Dim lSectorsPerCluster As Long
        Dim lBytesPerSector As Long
        Dim lFreeClusters As Long
        Dim lNumberOfClusters As Long
        Dim ret As Long

        ret = GetDiskFreeSpace(path, lSectorsPerCluster, lBytesPerSector, lFreeClusters, lNumberOfClusters)
        Return lBytesPerSector * lSectorsPerCluster * lFreeClusters
    End Function
End Class
